//
//  ZFContentSwitchCell.swift
//  map
//
//  Created by fyzq on 2024/2/18.
//

import UIKit

class ZFContentFoldView : ZFBaseView {

    private(set) var switchCell : ZFSwitchCustomCell!
    private(set) var contentView : UIView!
    var isOn :Bool = false {
        didSet{
            switchCell.switchBar.isOn = isOn
            UIView.animate(withDuration: 0.3) { [self] in
                self.contentView.isHidden = !isOn
                self.contentView.alpha = !self.contentView.isHidden ? 1 : 0
                self.layoutIfNeeded()
            }
        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        setZFLayerSwitchCell()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    fileprivate func setZFLayerSwitchCell(){
        switchCell = ZFSwitchCustomCell()
        switchCell.titleLabel.text = ""
        contentView = UIView()
        contentView.isHidden = true
        let group = ZFGroupCustomCell(arrangedSubviews: [switchCell,contentView])
        addSubview(group)
        group.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        switchCell.switchBar.rx.isOn.changed.subscribe(onNext: {[weak self] isOn in
            guard let self = self else {return}
            if self.contentView.subviews.count == 0 {return}
            self.isOn = isOn
        }).disposed(by: dis)
    }
}


/**
 十字架配置
 */
class ZFContentCrossView : ZFContentFoldView{
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setZFContentCrossView()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    fileprivate func setZFContentCrossView(){
        self.switchCell.titleLabel.text = "中心十字"
        
        let cell = ZFContentCustomCell()
        cell.titleLabel.font = UIFont.systemFont(ofSize: 13)
        cell.titleLabel.text = "图片"
//        cell.contentLabel.text = "图片"
        cell.arrow.image = R.image.ic_home_sz1()//?.jk_imageScaled(toFit:CGSize(width: 25, height: 20))
        cell.arrow.snp.updateConstraints { make in
            make.width.height.equalTo(25)
        }
   
        let cell1 = ZFContentCustomCell()
        cell1.titleLabel.font = UIFont.systemFont(ofSize: 13)
        cell1.titleLabel.text = "大小"
        cell1.contentLabel.text = "44"
        cell1.arrow.isHidden = true
        
        let group = ZFGroupCustomCell(arrangedSubviews: [cell,cell1])
        contentView.addSubview(group)
        group.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
    }
}


/**
 方位图
 */
class ZFContentCompassView : ZFContentFoldView{
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setZFContentCrossView()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    fileprivate func setZFContentCrossView(){
        switchCell.titleLabel.text = "中心十字"
        switchCell.imageView.isHidden = false
        switchCell.imageView.image = R.image.ic_mine_intergel()
        switchCell.imageView.snp.makeConstraints { make in
            make.width.height.equalTo(20)
        }
        
        let cell = ZFContentCustomCell()
        cell.titleLabel.font = UIFont.systemFont(ofSize: 13)
        cell.titleLabel.text = "图片"
        cell.arrow.image = R.image.ic_home_sz1()
        cell.arrow.snp.updateConstraints { make in
            make.width.height.equalTo(25)
        }
        
        let cell1 = ZFContentCustomCell()
        cell1.titleLabel.font = UIFont.systemFont(ofSize: 13)
        cell1.titleLabel.text = "大小"
        cell1.contentLabel.text = "44"
        cell1.arrow.isHidden = true
        
        let group = ZFGroupCustomCell(arrangedSubviews: [cell,cell1])
        contentView.addSubview(group)
        group.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
    }
}

/**
 等高线
 */
class ZFContentElevationView : ZFContentFoldView{
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setZFContentCrossView()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    fileprivate func setZFContentCrossView(){
        switchCell.titleLabel.text = "显示等高线"
        
        let cell = ZFCustomCell()
        cell.titleLabel.font = UIFont.systemFont(ofSize: 13)
        cell.titleLabel.text = "配置"
        contentView.addSubview(cell)
        cell.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
//        let cell2 = ZFContentCustomCell()
//        cell2.titleLabel.font = UIFont.systemFont(ofSize: 13)
//        cell2.titleLabel.text = "线粗"
//        cell2.arrow.isHidden = true
//        
//        let cell1 = ZFContentCustomCell()
//        cell1.titleLabel.font = UIFont.systemFont(ofSize: 13)
//        cell1.titleLabel.text = "边框颜色"
//        cell1.arrow.isHidden = true
//        
//        let cell3 = ZFContentCustomCell()
//        cell3.titleLabel.font = UIFont.systemFont(ofSize: 13)
//        cell3.titleLabel.text = "文字颜色"
//        cell3.arrow.isHidden = true
//        
//        let cell3 = ZFContentCustomCell()
//        cell3.titleLabel.font = UIFont.systemFont(ofSize: 13)
//        cell3.titleLabel.text = "颜色"
//        cell3.arrow.isHidden = true
   
        
//        let group = ZFGroupCustomCell(arrangedSubviews: [cell,cell1])
//        contentView.addSubview(group)
//        group.snp.makeConstraints { make in
//            make.edges.equalToSuperview()
//        }
        
    }
}

